package com.gutsyzhan.yusiailangchain4j.tools;

import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import dev.langchain4j.agent.tool.ToolMemoryId;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class MathTools {

    @Tool(name = "加法",  value = "计算两个数之和")
    public double add(@ToolMemoryId int memoryId,
                      @P(value = "加数1", required = true) double a,
                      @P(value = "加数2", required = true) double b ){
        log.info("调用加法运算，运算的memoryId:{}",memoryId);
        return a + b;
    }

    @Tool(name = "减法",  value = "计算两个数之差")
    public double sub(@ToolMemoryId int memoryId,
                      @P(value = "减数", required = true) double a,
                      @P(value = "被减数", required = true) double b ){
        log.info("调用减法运算，运算的memoryId:{}",memoryId);
        return a - b;
    }

    @Tool(name = "平方根",  value = "计算给定参数的平方根")
    public double sqrt(@ToolMemoryId int memoryId,
                      double a ){
        log.info("调用平方根运算，运算的memoryId:{}",memoryId);
        return Math.sqrt(a);
    }
}
